package studiodiva.portfolio.client.view;

import static com.google.gwt.query.client.GQuery.$;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

import studiodiva.portfolio.client.lib.view.Layout;
import studiodiva.portfolio.client.lib.view.View;
import studiodiva.portfolio.client.model.HasApplication;
import studiodiva.portfolio.client.model.titles.Titles.TitleType;
import studiodiva.portfolio.client.view.viewer.ViewerWidget;
import studiodiva.portfolio.client.view.workslides.WorksSlidesWidget;

public class PortfolioWidget extends View<FlowPanel> {

  interface Binder extends UiBinder<FlowPanel, PortfolioWidget> {}

  private static Binder uiBinder = GWT.create(Binder.class);

  @UiField
  TitleButton buttonDetails;
  @UiField
  TitleButton buttonDone;
  @UiField
  TitleButton buttonOffer;
  @UiField
  Widget buttonsPanel;
  @UiField
  ViewerWidget pageViewer;
  @UiField
  Widget portfolioWidget;
  @UiField
  WorksSlidesWidget worksSlides;

  public PortfolioWidget() {
    initWidget(uiBinder.createAndBindUi(this));
    Layout.center(buttonsPanel);
    $(asWidget()).fadeIn();
  }

  @Override
  public void initialize(HasApplication hasApplication) {
    super.initialize(hasApplication);
    worksSlides.initialize(this);
    pageViewer.initialize(this);
    buttonDetails.initialize(hasApplication, TitleType.contact);
    buttonDone.initialize(hasApplication, TitleType.done);
    buttonOffer.initialize(hasApplication, TitleType.offer);
  }

  public void show() {
    RootPanel.get().add(this);
  }
}
